package netbay;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Date;

public class TransactionTraffic {
	private Integer id;
	private Integer transactionId;
	private Date eventTime;
	private String process;
	private String action;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Integer getTransactionId() {
		return transactionId;
	}
	public void setTransactionId(Integer transactionId) {
		this.transactionId = transactionId;
	}
	public Date getEventTime() {
		return eventTime;
	}
	public void setEventTime(Date time) {
		this.eventTime = time;
	}
	public String getProcess() {
		return process;
	}
	public void setProcess(String process) {
		this.process = process;
	}
	public String getAction() {
		return action;
	}
	public void setAction(String action) {
		this.action = action;
	}
	
	public PreparedStatement convertInsert(Connection con) {
		
		PreparedStatement st = null;
		try {
		st = con.prepareStatement("insert into traffic(id,transactionid,time,action,process) values(NULL,?,?,?,?)");
		
		st.setInt(1, getTransactionId());
		st.setTimestamp(2, new java.sql.Timestamp(getEventTime().getTime()));
		st.setString(3, getAction());
		st.setString(4, getProcess());
		
		
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		
		return st;
	}
	
	public PreparedStatement convertQueryTraffic(Connection con,TransactionLog log){
		
		PreparedStatement st = null;
		try {
		st = con.prepareStatement("select * from traffic where transactionid = ?");
		
		st.setInt(1, log.getId());
		
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		
		return st;
	}
	
}
